#Author: Tanyong
# *-* coding:utf8 *-*
# @time       : 18-7-16 下午8:00
# @Author     : Tanyong
# @Site       : 
# @File       : Models.py
# @Software   : PyCharm
from datetime import datetime

from info import db


class Info(db.Model):
    __tablename__="info"
    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(6), unique=True)
    short = db.Column(db.String(50))
    chg = db.Column(db.String(50))
    turnover = db.Column(db.String(50))
    price = db.Column(db.String(50))
    highs = db.Column(db.String(50))
    time = db.Column(db.DateTime, default=datetime.now())
    focus = db.relationship("Focus", backref="infos")

    def __repr__(self):
        return "<Info %r>" % self.id

class Focus(db.Model):
    __tablename__ = "focus"
    id = db.Column(db.Integer, primary_key=True)
    note_info = db.Column(db.String(64))
    info_id = db.Column(db.Integer, db.ForeignKey("info.id"))

    def __repr__(self):
        return "<Focus %r>" % self.id

# if __name__ == "__main__":
#
#     db.create_all()
#     f1 = Focus(note_info = "利好", info_id='1' )
#     f2 = Focus(note_info="sss", info_id='3')
#     f3 = Focus(note_info="aaaa", info_id='94')
#     db.session.add_all([f1, f2, f3])
#     db.session.commit()
#
    # app.run()